#ifndef __APP_RINGBUFF_H__
#define __APP_RINGBUFF_H__


#include <stdint.h>
#include <string.h>
#include <stdbool.h>
#include <stdio.h>

#define ADV_DATA_QUEUE_LEN          (16)


typedef struct
{
    uint8_t len;
    uint8_t advType;
    uint8_t vendorCustomCode[2];
    uint8_t mac[6];
    uint8_t devType;
    uint8_t frameId;
    uint8_t magneticValue[2];
    uint8_t tamperProof;
    uint8_t move;
    uint8_t TotalNumberOfTans[2];
    uint8_t RFU[7];
    uint8_t softVersion[2];
    uint8_t lrc;
}advDataFrame_t;



typedef struct
{
    uint8_t mac[6];
    uint8_t len;
    uint8_t data[31];
}bleAdvInfo_t;

typedef struct
{
    uint8_t WriteIdx;
    uint8_t ReadIdx;
    uint8_t ToRead;
    uint8_t Lock;
    bleAdvInfo_t advData[ADV_DATA_QUEUE_LEN];
}bleAdvDataQueue_t;

extern volatile bleAdvDataQueue_t bleAdvDataQueue;


void bleAdvDataQueueInit(void);

int bleAdvDataSave(uint8_t *pMac, uint8_t *pData, uint8_t len);
int bleAdvDataRead(uint8_t *pMac, uint8_t *pData, uint8_t *pLen);

int bleAdvDataHandle(uint8_t *pMac, uint8_t *pData, uint8_t len);
int bleAdvDataSaveHandle(uint8_t *pMac, uint8_t *pData, uint8_t len, int rssi);

#endif  /* __APP_RINGBUFF_H__ */


